package com.zhuhjay.service.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuhjay.service.system.mapper.SystemRoleMenuMapper;
import com.zhuhjay.service.system.model.entity.SystemRoleMenu;
import com.zhuhjay.service.system.service.SystemRoleMenuService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Zhuhjay
 * @since 2023-02-13
 */
@Service
public class SystemRoleMenuServiceImpl extends ServiceImpl<SystemRoleMenuMapper, SystemRoleMenu> implements SystemRoleMenuService {

    @Override
    public List<Integer> getMenuIdsByRoleId(Integer roleId) {
        return this.lambdaQuery()
                .eq(SystemRoleMenu::getRoleId, roleId).orderByDesc(SystemRoleMenu::getMenuId).list()
                .stream().map(SystemRoleMenu::getMenuId).collect(Collectors.toList());
    }
}
